package mule;

import static org.junit.Assert.*;

import java.awt.Color;

import org.junit.Test;

public class TileProductionTest {

	@Test
	public void testPlainProduction() {
		/**
		 * Plain
		 * 
		 * Food Rate: 2 Energy Rate: 3 Ore Rate: 1 Cost: 300
		 */

		Plain plain = new Plain();
		Player player = new Player(1, 1, Color.RED, "test");
		Mule foodMule = new Mule("Food Mule");
		Mule energyMule = new Mule("Energy Mule");
		Mule oreMule = new Mule("Ore Mule");

		// Default values of a flapper player
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		plain.setOwner(player);
		plain.production();

		// values shouldn't change because plain does not have a mule placed on
		// it
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		// With a food mule placed, the player should gain 2 food and lose 1
		// energy
		plain.setMule(foodMule);
		plain.production();
		assertEquals(10, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an energy mule placed, the player should gain 3 energy and then
		// lose 1 energy, for a total net gain of 2 energy
		plain.setMule(energyMule);
		plain.production();
		assertEquals(10, player.getFood());
		assertEquals(5, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an ore mule placed, the player should gain 1 ore and lose 1
		// energy
		plain.setMule(oreMule);
		plain.production();
		assertEquals(10, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(1, player.getOre());

		// after setting the mule to null, player resources should stay the same
		plain.setMule(null);
		plain.production();
		assertEquals(10, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(1, player.getOre());

	}

	@Test
	public void testRiverProduction() {
		/**
		 * River
		 * 
		 * Food Rate: 4 Energy Rate: 2 Ore Rate: 0 Cost: 300
		 */

		River river = new River();
		Player player = new Player(1, 1, Color.RED, "test");
		Mule foodMule = new Mule("Food Mule");
		Mule energyMule = new Mule("Energy Mule");
		Mule oreMule = new Mule("Ore Mule");

		// Default values of a flapper player
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		river.setOwner(player);
		river.production();

		// values shouldn't change because river does not have a mule placed on
		// it
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		// With a food mule placed, the player should gain 2 food and lose 1
		// energy
		river.setMule(foodMule);
		river.production();
		assertEquals(12, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an energy mule placed, the player should gain 2 energy and then
		// lose 1 energy, for a total net gain of 1 energy
		river.setMule(energyMule);
		river.production();
		assertEquals(12, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an ore mule placed, the player should gain 0 ore and lose 1
		// energy
		river.setMule(oreMule);
		river.production();
		assertEquals(12, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// after setting the mule to null, player resources should stay the same
		river.setMule(null);
		river.production();
		assertEquals(12, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());
	}

	@Test
	public void testMountain1Production() {
		/**
		 * Mountain1
		 * 
		 * Food Rate: 1 Energy Rate: 1 Ore Rate: 2 Cost: 300
		 */

		Mountain1 mountain1 = new Mountain1();
		Player player = new Player(1, 1, Color.RED, "test");
		Mule foodMule = new Mule("Food Mule");
		Mule energyMule = new Mule("Energy Mule");
		Mule oreMule = new Mule("Ore Mule");

		// Default values of a flapper player
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		mountain1.setOwner(player);
		mountain1.production();

		// values shouldn't change because mountain1 does not have a mule placed
		// on it
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		// With a food mule placed, the player should gain 1 food and lose 1
		// energy
		mountain1.setMule(foodMule);
		mountain1.production();
		assertEquals(9, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an energy mule placed, the player should gain 1 energy and then
		// lose 1 energy, for a total net gain of 0 energy
		mountain1.setMule(energyMule);
		mountain1.production();
		assertEquals(9, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an ore mule placed, the player should gain 2 ore and lose 1
		// energy
		mountain1.setMule(oreMule);
		mountain1.production();
		assertEquals(9, player.getFood());
		assertEquals(2, player.getEnergy());
		assertEquals(2, player.getOre());

		// after setting the mule to null, player resources should stay the same
		mountain1.setMule(null);
		mountain1.production();
		assertEquals(9, player.getFood());
		assertEquals(2, player.getEnergy());
		assertEquals(2, player.getOre());
	}

	@Test
	public void testMountain2Production() {
		/**
		 * Mountain2
		 * 
		 * Food Rate: 1 Energy Rate: 1 Ore Rate: 3 Cost: 300
		 */

		Mountain2 mountain2 = new Mountain2();
		Player player = new Player(1, 1, Color.RED, "test");
		Mule foodMule = new Mule("Food Mule");
		Mule energyMule = new Mule("Energy Mule");
		Mule oreMule = new Mule("Ore Mule");

		// Default values of a flapper player
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		mountain2.setOwner(player);
		mountain2.production();

		// values shouldn't change because mountain2 does not have a mule placed
		// on it
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		// With a food mule placed, the player should gain 1 food and lose 1
		// energy
		mountain2.setMule(foodMule);
		mountain2.production();
		assertEquals(9, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an energy mule placed, the player should gain 1 energy and then
		// lose 1 energy, for a total net gain of 0 energy
		mountain2.setMule(energyMule);
		mountain2.production();
		assertEquals(9, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an ore mule placed, the player should gain 3 ore and lose 1
		// energy
		mountain2.setMule(oreMule);
		mountain2.production();
		assertEquals(9, player.getFood());
		assertEquals(2, player.getEnergy());
		assertEquals(3, player.getOre());

		// after setting the mule to null, player resources should stay the same
		mountain2.setMule(null);
		mountain2.production();
		assertEquals(9, player.getFood());
		assertEquals(2, player.getEnergy());
		assertEquals(3, player.getOre());
	}

	@Test
	public void testMountain3Production() {
		/**
		 * Mountain3
		 * 
		 * Food Rate: 1 Energy Rate: 1 Ore Rate: 4 Cost: 300
		 */

		Mountain3 mountain3 = new Mountain3();
		Player player = new Player(1, 1, Color.RED, "test");
		Mule foodMule = new Mule("Food Mule");
		Mule energyMule = new Mule("Energy Mule");
		Mule oreMule = new Mule("Ore Mule");

		// Default values of a flapper player
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		mountain3.setOwner(player);
		mountain3.production();

		// values shouldn't change because mountain3 does not have a mule placed
		// on it
		assertEquals(1600, player.getMoney());
		assertEquals(8, player.getFood());
		assertEquals(4, player.getEnergy());
		assertEquals(0, player.getOre());

		// With a food mule placed, the player should gain 1 food and lose 1
		// energy
		mountain3.setMule(foodMule);
		mountain3.production();
		assertEquals(9, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an energy mule placed, the player should gain 1 energy and then
		// lose 1 energy, for a total net gain of 0 energy
		mountain3.setMule(energyMule);
		mountain3.production();
		assertEquals(9, player.getFood());
		assertEquals(3, player.getEnergy());
		assertEquals(0, player.getOre());

		// With an ore mule placed, the player should gain 4 ore and lose 1
		// energy
		mountain3.setMule(oreMule);
		mountain3.production();
		assertEquals(9, player.getFood());
		assertEquals(2, player.getEnergy());
		assertEquals(4, player.getOre());

		// after setting the mule to null, player resources should stay the same
		mountain3.setMule(null);
		mountain3.production();
		assertEquals(9, player.getFood());
		assertEquals(2, player.getEnergy());
		assertEquals(4, player.getOre());
	}

}
